package day0710;

import java.util.Arrays;

public class Test3 {
    public static void main(String[] args) {
        //1.
        double[]  scores=new double[4];
        //数组的类型是char[]，  元素的类型是char
        char[]    letters={'A' , 'B', 'C', 'D'};

        //2.
        scores[0]=3.14;
        letters[0]='Y';
        //给数组的最后位置存入'd'
        letters[letters.length-1]='d';
        scores[ scores.length-1 ]=96.7;

        System.out.println(scores[0]);
        System.out.println(scores[1]);//0.0
        System.out.println(scores[2]);//0.0

        System.out.println(letters[letters.length-1]);
        System.out.println(letters[letters.length-2]);
        System.out.println(letters[letters.length-3]);


        int[]  a3={4, 5, 6, 9};
        String rs=Arrays.toString(a3);
        System.out.println(rs);

        System.out.println(Arrays.toString(a3));







        String[]   names={"jone","james","tom","bob"};
        String[]   names2=new String[4];

        //System.arraycopy(复制元素的数组名，复制元素的起始位置，存入元素的起始位置，放元素的数组名， 元素个数);
        System.arraycopy(names,0,names2,0, 2);
        System.out.println(Arrays.toString(names2));
















        String[]   ns  =            {"jone","james","tom","bob"};
        copyNs(ns);
        //{"jone","james","tom","jone"};
        System.out.println(Arrays.toString(ns));// {"jone","james","tom","jone"};
    }




    static void copyNs(String[]  ns2){// {"jone","james","tom","jone"};
        System.arraycopy(ns2,0,ns2,3, 1);
        System.out.println(Arrays.toString(ns2));
    }
}
